<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%--
  Created by IntelliJ IDEA.
  User: IFT8
  Date: 2015/3/16
  Time: 20:25
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title></title>
</head>
<body>
<h1>遍历</h1>
<%
    String []names={"name1","name2","name3","name4","name5"};
    pageContext.setAttribute("names",names);
%>
<c:forEach var="name" items="${names}">
    ${name}
</c:forEach>
<h3>遍历Map</h3>
<%
    Map<String,String> map=new HashMap<String, String>();
    map.put("name","Li");
    map.put("age","18");
    map.put("gender","Man");
    pageContext.setAttribute("map",map);
%>
<c:forEach items="${map}" var="entry">
    ${entry.key}:${entry.value}<br>
</c:forEach>

<h3>执行给定代码指定次数</h3>
<c:forEach begin="0" end="10" step="2" var="i">
    ${i}
</c:forEach>
<h3><c:out value="<c:forEach>"></c:out>的varStatus属性，用来存放现在指到之成员的相关信息（index，count，first，last）</h3>
<hr>
<h4>遍历10到100的偶数，如果数字所在的位置是3的倍数，显示成红色</h4>
<h5>【注意】varStatus.index得到的是当前数在自然数中的索引<br>
位置得用varStatus.count</h5>
<c:forEach begin="10" end="100" step="2" var="num" varStatus="i">
    <c:if test="${i.count%3==0}">
        <span style="color: red; "> ${num}</span>
    </c:if>
    <c:if test="${i.count%3!=0}">
        ${num}
    </c:if>
</c:forEach>
</body>
</html>
